<?
if(!empty($fee_cat)){
	foreach($fee_cat as $key => $value){
		$all_fees[$value->fee_cat_id] = $value->fee_cat_name;
	}
}else{
		$all_fees = FALSE;
}

if(!empty($yr_level_fees)){
	foreach($yr_level_fees as $key => $value){
		$ass_fees[$value->fee_cat_id] = $value->fee_cat_name;
	}
}else{
	$ass_fees = FALSE;
}	

if(!empty($all_fees) AND !empty($ass_fees)){
		foreach($all_fees as $key => $value){
				if(!array_key_exists($key,$ass_fees)){
					$unass_fees[$key] = $value;
				}
		}
}else{
	$unass_fees = $all_fees;
}
?>

<div class="grid_9">

<?php if($this->session->flashdata('type')): ?>
	<div class="<?php echo $this->session->flashdata('type')?>"><?php echo $this->session->flashdata('msg')?></div>
<?php endif; ?>

<div class="inner-border">
<h6>Edit Year Level</h6>
<?php if(!empty($yr_level)): ?>
	<?php
		$formAttrib = array('id' => 'edityearlevel', 'class' => 'admin-form');
		foreach($yr_level as $db_entry){
			$hiddenAttrib = array('level_id' => $db_entry->id);
			$levelNameAttrib = array('name' => 'level_name', 'value' => $db_entry->level_name, 'id' => 'levelname');
		}
		echo form_open('post/edit_year_level', $formAttrib);
	?>
    
    <div class="input-block">
    <?php
		echo form_label('Level Name:', 'levelname');
		echo form_input($levelNameAttrib);
		echo form_hidden($hiddenAttrib);

	?>
    </div>
	
	<table>
		<tbody class="tabular">
			<tr><td><h6>(<?=count($ass_fees);?>) Assigned Fee</h6></td></tr>
			<?if(!empty($ass_fees)):?>
				<?foreach($ass_fees as $key => $value):?>
					<tr><td><input type="checkbox" name="fee[]" value="<?=$key;?>"checked/> <?=$value;?></td></tr>
				<?endforeach;?>
			<?else:?>
				<tr><td><div class="notice">No fees assigned for this level</div></td></tr>
			<?endif;?>
			
			<tr><td><h6>(<?=count($unass_fees);?>) Available fee to assign</h6></td></tr>
			<?if(!empty($unass_fees)):?>
				<?foreach($unass_fees as $key => $value):?>
					<tr><td><input type="checkbox" name="fee[]" value="<?=$key;?>"/> <?=$value;?></td></tr>
				<?endforeach;?>
			<?else:?>
				<tr><td><div class="notice">No fees assigned in fee category</div></td></tr>
			<?endif;?>
		</tbody>
	</table>
	<? echo form_submit('update', 'Update');?>
	</form>
<?php else: ?>
	<div class="notice">Please try again</div>
<?php endif; ?>
<a href="<?php echo site_url('admin/level') ?>" class="btn">Back</a>	
</div>
</div>